package com.kefu.call.vo;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.kefu.basic.model.BasicStatusConfig;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractSearchVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.util.Objects;
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "列表")
public class CallStatusConfigSearchVo extends AbstractSearchVo{
    @ApiModelProperty(value = "状态名称")
    private String statusName;
    @ApiModelProperty(value = "状态,1=正常，0=禁用")
    private Integer status;
    @Override
    public LambdaQueryWrapper<BasicStatusConfig> lambdaQuery() {
        LambdaQueryWrapper<BasicStatusConfig> wrapper = Wrappers.lambdaQuery(BasicStatusConfig.class);
        wrapper.like(StrUtil.isNotBlank(statusName), BasicStatusConfig::getStatusName, statusName);
        wrapper.eq(BasicStatusConfig::getStatusType, 2);
        wrapper.eq(Objects.nonNull(status), BasicStatusConfig::getStatus, status);
        wrapper.eq(BasicStatusConfig::getTenantId, KefuContext.getTid());
        wrapper.orderByAsc(BasicStatusConfig::getStatusCode);
        return wrapper;
    }
}
